package com.usion.controller;

import cn.jiyun.entity.ResultClass;
import cn.jiyun.entity.day13.User;
import com.usion.service.UserFeginService;
import com.usion.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author sjt
 * @Date 2023/8/22 10:55
 * @PackageName: com.usion.controller.UserController
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserFeginService userFeginService;
    @Autowired
    UserService userService;

    @PostMapping("/userLogin")
    private ResultClass userLogin(@RequestBody User user){
        try{
            return userService.userLogin(user);
        } catch (Exception e) {
            return ResultClass.error().Message("登录失败");
        }
    }
    @GetMapping("/findLoginUser")
    private ResultClass findLoginUser(HttpServletRequest request){
        return userService.findLoginUser(request);
    }
}
